
if exists(select name from sysobjects where name = 'sp_TuanGetAll')
	drop proc sp_TuanGetAll
go
/*
	Created by: Phuoc NH
	Created on: 5/12/2013 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_TuanGetAll.sql
*/

create proc sp_TuanGetAll
@HocKy tinyint
as
begin
set dateformat mdy
	if(@HocKy=3)
		begin
			select Tuan, CONVERT(varchar(12), CONVERT(datetime, NgayDau),103) as ngayDau, CONVERT( varchar(10), CONVERT (datetime, NgayCuoi), 103) as ngayCuoi from tuan 
		end
		else
	begin
		if(@HocKy=1)
			begin
				select Tuan, CONVERT(varchar(12), CONVERT(datetime, NgayDau),103) as ngayDau, CONVERT( varchar(10), CONVERT (datetime, NgayCuoi), 103) as ngayCuoi from tuan where tuan<=26	
			end
		else
			begin
				select Tuan, CONVERT(varchar(12), CONVERT(datetime, NgayDau),103) as ngayDau, CONVERT( varchar(10), CONVERT (datetime, NgayCuoi), 103) as ngayCuoi from tuan where tuan>26	
			end 
	end
end

